package leetcode.code0951;

import leetcode.IDebug;
import leetcode.helper.tree.TreeNode;

public class Solution implements IDebug {
	public boolean flipEquiv(TreeNode root1, TreeNode root2) {
		if (root1 == null && root2 == null) {
			return true;
		} else if (root1 != null && root2 != null) {
			if (root1.val == root2.val) {
				boolean ans1 = this.flipEquiv(root1.left, root2.left) && this.flipEquiv(root1.right, root2.right);
				if (ans1)
					return true;
				boolean ans2 = this.flipEquiv(root1.left, root2.right) && this.flipEquiv(root1.right, root2.left);
				if (ans2)
					return true;
			}
		}
		return false;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
